import csv

# 定义输入和输出文件路径
input_file = 'Tra.csv'
output_file = 'train.csv'
# input_file = 'Test.csv'
# output_file = 'test.csv'

# 打开输入文件和输出文件
with open(input_file, 'r') as file_in, open(output_file, 'w', newline='') as file_out:
    reader = csv.reader(file_in)
    writer = csv.writer(file_out,delimiter=',')

    # 写入新的表头
    # writer.writerow(['video_id', 'frames', 'label_id'])
    next(reader) #去除表头
    # 逐行读取输入文件并转换格式
    for row in reader:
        video_id, label, frames, label_id, shape, file_format = row

        # 写入新的一行数据
        writer.writerow(["/mydata/"+video_id+".mp4", label_id])

print('转换完成！')